﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfUMLTry1.Model
{
    public class PlayerCharacter : AbstractCreature
    {
        private static readonly List<Int32> expLimit = new List<int>() {5, 10, 20, 30, 40, 50, 70, 100}; 
 
        public PlayerCharacter(String _name): base(_name)   //new player - lvl 0 and give 0 xp
        {
            givenExp = 0;
            level = 1;
        }

        public PlayerCharacter(String[] loadedData, String name) : base(name)   //loading from file - fill up stats
        {
            level = Int32.Parse(loadedData[1]);
            givenExp = Int32.Parse(loadedData[2]);
            bMaxHP = Int32.Parse(loadedData[3]);
            bMaxFuel = Int32.Parse(loadedData[4]);
            setFuelType(loadedData[5]);
            bStr = Int32.Parse(loadedData[6]);
            bAgi = Int32.Parse(loadedData[7]); 
            bVit = Int32.Parse(loadedData[8]);
            bWis = Int32.Parse(loadedData[9]);
            bLuk = Int32.Parse(loadedData[10]);
            HP = maxHP;
            fuel = maxFuel;
        }

        public override int experience
        {
            get
            {
                return base.experience;
            }
            set
            {
                if (value > 0)
                {
                    base.experience = value;
                    if (base.experience > expLimit[base.level - 1])
                        playerLevelUp();
                }
            }
        }

        public void useSkill(Int32 index, AbstractCreature target)
        {
            skillSet[index].activate(this, target);
        }

        public override String getBackSavingText()
        {
            return base.getBackSavingText();
        }

        protected virtual void playerLevelUp() {}
        protected virtual void setSkillSet() { }

        public virtual void StepInToNewFight() { }
        public virtual void RestInTheInn() { }

    }
}
